'use strict';

goog.provide('Blockly.Arduino.Data');

goog.require('Blockly.Arduino');



// Blockly.Arduino.data_variable = function() {
//   // Variable setter.
//
//   var varName = Blockly.Arduino.variableDB_.getName(this.getFieldValue('VARIABLE'),
//       Blockly.Variables.NAME_TYPE);
//   Blockly.Arduino.setups_['setup_var' + varName] = varName + '\n';
//   return '';
// };


Blockly.Arduino.data_variable = function() {
  // Variable getter.
  var pin=this.getFieldValue('VARIABLE');

  var varName = Blockly.Arduino.variableDB_.getName(pin,
      Blockly.VARIABLE_CATEGORY_NAME);
  // Blockly.Arduino.setups_['setup_var' + varName] = varName + ' = ' + 0 + ';\n';
  var code=varName;
  return [code, Blockly.Arduino.ORDER_ATOMIC];
};


Blockly.Arduino.data_setvariableto = function() {
  // Variable setter.
  var argument0 = Blockly.Arduino.valueToCode(this, 'VALUE',
      Blockly.Arduino.ORDER_ASSIGNMENT) || 0;
  var varName = Blockly.Arduino.variableDB_.getName(this.getFieldValue('VARIABLE'),
      Blockly.VARIABLE_CATEGORY_NAME);
  var new_arg=argument0;
  Blockly.Arduino.setups_['setup_var' + varName] = varName + ' = ' + new_arg + ';\n';
  return  '';
};


Blockly.Arduino.data_changevariableby = function() {
  // Variable setter.
  var argument0 = Blockly.Arduino.valueToCode(this, 'VALUE',
      Blockly.Arduino.ORDER_ASSIGNMENT) || '0';
  var varName = Blockly.Arduino.variableDB_.getName(this.getFieldValue('VARIABLE'),
      Blockly.VARIABLE_CATEGORY_NAME);
  var new_arg=argument0;
  return varName + ' = ' + new_arg + ';\n';
};


